  <template>
	<div class="contain">

		<h3>{{photoinfo.title}}</h3>
		<p class="subtitle">
			<span>发表时间：{{photoinfo.add_time |dateFormat}}</span>
			<span>点击：{{photoinfo.click}}次</span>
		</p>
		<hr>
		<vue-preview :slides="slide1" @close="handleClose" class="thumbs"></vue-preview>
		<div class="content" v-html="photoinfo.content"></div>
		<cmt-box :id="id"></cmt-box>
	</div>
</template>

<script>
	import comment from '../subcomment/comment.vue'
	export default {
		data() {
			return {
				photoinfo: [],
				id: this.$route.params.id,
				slide1: [

				]
			}
		},
		created() {
			this.getPhotoInfo();
			this.getThumbs();
		},

		methods: {
			getPhotoInfo() {
				this.$http.get("api/getimageInfo/" + this.$route.params.id).then(data => {

					if(data.body.status === 0) {
						this.photoinfo = data.body.message[0]
						//					
					}

				})
			},
			//补全所有图片的宽和高
			getThumbs() {
				this.$http.get("api/getthumimages/" + this.id).then(data => {

					if(data.body.status === 0) {

						data.body.message.forEach((item, i) => {

							item.w = 300;
							item.h = 200;
							item.msrc = item.src
						})
						this.slide1 = data.body.message

					}

				})
			},
			handleClose() {
				console.log('close event')
			}
		},
		components: {
			'cmt-box': comment
		}
	}
</script>

<style lang="less">
	.contain {
		padding: 3px;
		h3 {
			font-size: 15px;
			text-align: center;
			color: #26a2ff;
			margin: 15px 0;
		}
		.subtitle {
			display: flex;
			font-size: 13px;
			justify-content: space-between;
		}
		.content {
			font-size: 13px;
			line-height: 30px;
		}
		.my-gallery {
			display: flex;
			flex-wrap: wrap;
			width: 100%;
		}
		.thumbs {
			text-align: center;
			margin: 0;
			padding: 0;
			height: 220px;
			figure {
				margin: 5px 10px;
				padding: 0;
				
				width: 100px;
				height: 100px;
			}
			img {
				flex: 1;
				box-shadow: 0 0  6px #999;
				width: 100px;
				height: 100px;
			}
		}
	}
</style>